var express = require('express');
var path=require('path');
var router = express.Router();
var fs=require('fs');

router.post('/',function (req, res) {
    var postData = "";
    req.setEncoding("utf8");
    req.addListener("data", function(data) {
        postData += data;
    });
    req.addListener("end", function() {
        if(postData){
            fs.writeFile(path.join(__dirname,'..','..','mvc-new','bundles','bundle','model','test.json'),postData,function (err) {
                if(err){
                    res.end('save error');
                }else{
                    res.end('save success');
                }
            });
        }
    });
    
});

module.exports = router;
